home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / PGM_TOOL / TCUNIT / WINDTEST.PAS < prev   
Pascal/Delphi Source File  |  1989-07-02  |  2KB  |  88 lines

  1. (*
  2.  *    PROGRAM : WindTest example program
  3.  *    SYSTEM  : Turbo Pascal 4.0, 5.0, and 5.5
  4.  *    AUTHOR  : (C) 1988, 1989 by Tom Swan
  5.  *)
  6.  
  7. PROGRAM WindTest;
  8.  
  9.  
  10. USES  Crt, WindGlob;
  11.  
  12.  
  13. PROCEDURE WriteAt( x, y : Word; ch : Char );
  14.  
  15. { Display character ch at text display location (x,y) }
  16.  
  17. BEGIN
  18.    GotoXY( x, y );
  19.    Write( ch )
  20. END; { WriteAt }
  21.  
  22.  
  23. PROCEDURE DrawBox( left, top, right, bottom : Word );
  24.  
  25. { Outline a box on the text display }
  26.  
  27. VAR   i : Integer;      { FOR-loop control variable }
  28.  
  29. BEGIN
  30.    WriteAt( left, top, #213 );
  31.    WriteAt( right, top, #184 );
  32.    WriteAt( left, bottom, #192 );
  33.    WriteAt( right, bottom, #217 );
  34.    FOR i := left+1 TO right-1 DO
  35.    BEGIN
  36.       WriteAt( i, top, #205 );
  37.       WriteAt( i, bottom, #196 )
  38.    END; { for }
  39.    FOR i := top+1 TO bottom-1 DO
  40.    BEGIN
  41.       WriteAt( left, i, #179 );
  42.       WriteAt( right, i, #179 )
  43.    END { for }
  44. END; { DrawBox }
  45.  
  46.  
  47. PROCEDURE CenterTitle( s : String; left, top, right : Word );
  48.  
  49. { Center string s at row = top between left and right }
  50.  
  51. VAR   k : Integer;   { Spaces to offset title from left }
  52.  
  53. BEGIN
  54.    k := ( ( ( right - left ) + 1 ) - Length( s ) ) DIV 2;
  55.    GotoXY( left + k, top );
  56.    Write( s )
  57. END; { CenterTitle }
  58.  
  59.  
  60. PROCEDURE OpenWindow( left, top, right, bottom : Word; title : String );
  61.  
  62. { Display blank window, restricting subsequent text output to within
  63. the window's borders. }
  64.  
  65. BEGIN
  66.    TextColor( WBForeColor );
  67.    TextBackground( WBBackColor );
  68.    DrawBox( left, top, right, bottom );
  69.    CenterTitle( title, left, top, right );
  70.    Window( left+1, top+1, right-1, bottom-1 )
  71. END; { OpenWindow }
  72.  
  73.  
  74. BEGIN
  75.    ClrScr;
  76.    OpenWindow( 10, 3, 50, 12, WTitle );
  77.    TextColor( WTForeColor );
  78.    TextBackground( WTBackColor );
  79.    ClrScr;
  80.    WHILE NOT Keypressed DO
  81.    BEGIN
  82.       Delay( 15 );  { "Slow down, you move too fast..." }
  83.       Write( Chr( 32 + Random(144) ) )
  84.    END; { while }
  85.    Window( 1, 1, 80, 25 );
  86.    GotoXY( 1, 25 )
  87. END.
  88.